
public class Flight {
	private int _bookedSeats;
	private int _totalSeats;
	private Date _flightDate;
	private String _origin;
	private String _destination;
	
	
	public Flight (int totalSeats,Date flightDate,String origin,String destination)
	{
		_totalSeats = totalSeats;
		_flightDate = new Date (flightDate);
		_origin = origin;
		_destination = destination;
		_bookedSeats = 0;
	}
	

	public Flight(Flight fl)
	{
		_totalSeats = fl._totalSeats;
		_flightDate = new Date (fl._flightDate);
		_origin = fl._origin;
		_destination = fl._destination;
		_bookedSeats = fl._bookedSeats;
	}
	
	public int getBookedSeats()
	{
		return _bookedSeats;
	}
	
	public int getTotalSeats()
	{
		return _totalSeats;
	}
	
	public Date getFlightDate()
	{
		return new Date (_flightDate);
	}
	
	public String getOrigin()
	{
		return _origin;
	}
	
	public String getDestination()
	{
		return _destination;
	}
	
	
	public void setFlightDate (Date flightd)
	{
		_flightDate = new Date(flightd);
	}
	

	public void setTotalSeats(int seats)
	{
		_totalSeats = seats;
	}
	

	public void setOrigin (String origin)
	{
		_origin = origin;
		
	}
	
	
	public void setDestination (String dest)
	{
		_destination = dest;
	}
	
	public void setBookedSeats (int seats)
	{
		_bookedSeats = seats;
	}
	
	public String toString ()
	{
		
		return("Flight Details:\n " +
		"\n\t origin: " + this._origin +
		"\n\t destination: " + this._destination + 
		"\n\t flight date: " + this._flightDate +
		"\n\t total seats: " + this._totalSeats +
		"\n\t booked seats: " + this._bookedSeats );
				
	}
	
	public boolean isEquals(Flight fl)
	{
		if (  fl._flightDate.isEqual(fl._flightDate ) &&
				_origin.equals( fl._origin ) &&
				_destination.equals ( fl._destination )

			)
		return true ;
		
		return false;
		
	}
	
	public boolean isFull()
	{
		if (this._bookedSeats >= this._totalSeats)
			return true;
		
		return false;
	}
	
	public int placesLeft()
	{
		return this._totalSeats - this._bookedSeats;
		
	}
	
	public boolean bookFlight(int seats)
	{
		if ( this.placesLeft() >= seats)
		{
			this._bookedSeats += seats;
			return true;
		}
		
		return false;	
		
		
	}
	/**
	 * Increment FlightDate Month by 1
	 */
	public void incrementMonth()
	{
		
		int tempMonth = _flightDate.getMonth();
		int tempYear = _flightDate.getYear();
		
		
		//End of the Year we should restart month count , and increment year
		if(tempMonth==12)
		{
			tempMonth=1;
			tempYear++;
			_flightDate.setYear(tempYear);
		}
		else
		{
			tempMonth++;
		}
		
		_flightDate.setMonth(tempMonth);
		
	}
}
